package com.zs.java.blockingqueue;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

/**
 * 使用优先级队列实现的无界阻塞队列
 *
 * @author madison
 * @description
 * @date 2021/6/1 22:54
 */
public class DelayQueueTest {
    public static void main(String[] args) {
        DelayQueue<Delayed> queue = new DelayQueue<>();
        queue.add(new Delayed() {
            @Override
            public long getDelay(TimeUnit unit) {
                return 1000;
            }

            @Override
            public int compareTo(Delayed o) {
                return 0;
            }
        });

        queue.poll();
        System.out.println(queue);
    }
}
